home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 October / Enter 10 2006.iso / boot / isolinux / initrd / in / usr / lib / setup / pkgtool < prev    next >
Encoding:
Text File  |  2004-06-05  |  21.1 KB  |  708 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1993, 1994, 1995, 1996, 1997,
  4. #    1998, 1999  Patrick Volkerding,  Moorhead, MN  USA
  5. # Copyright 2001  Slackware Linux, Inc.,  Concord, CA  USA
  6. #    All rights reserved.
  7. #
  8. # Redistribution and use of this script, with or without modification, is 
  9. # permitted provided that the following conditions are met:
  10. #
  11. # 1. Redistributions of this script must retain the above copyright
  12. #    notice, this list of conditions and the following disclaimer.
  13. #
  14. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  15. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
  16. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  17. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
  18. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
  21. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
  22. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
  23. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. #
  25.  
  26. # Wed, 27 Apr 1994 00:06:50 -0700 (PDT)
  27. # Optimization by David Hinds.
  28.  
  29. SOURCE_DIR=/var/log/mount
  30. ASK="tagfiles"
  31. if [ -L /bin/chmod -a -L /bin/chown ]; then # probably on the bootdisk using busybox
  32.  TARGET_DIR=/mnt
  33.  TMP=/mnt/var/log/setup/tmp
  34.  if mount | grep "on /mnt" 1> /dev/null 2>&1 ; then # good
  35.   true
  36.  else # bad
  37.   echo
  38.   echo
  39.   echo "You can't run pkgtool from the rootdisk until you've mounted your Linux"
  40.   echo "partitions beneath /mnt. Here are some examples of this:"
  41.   echo
  42.   echo "If your root partition is /dev/hda1, and is using ext2fs, you would type:"
  43.   echo "mount /dev/hda1 /mnt -t ext2"
  44.   echo
  45.   echo "Then, supposing your /usr partition is /dev/hda2, you must do this:"
  46.   echo "mount /dev/hda2 /mnt/usr -t ext2"
  47.   echo
  48.   echo "Please mount your Linux partitions and then run pkgtool again."
  49.   echo
  50.   exit
  51.  fi
  52. else
  53.  TARGET_DIR=/
  54.  TMP=/var/log/setup/tmp
  55. fi
  56. if [ ! -d $TMP ]; then
  57.  mkdir -p $TMP
  58.  chmod 700 $TMP
  59.  fi
  60. ADM_DIR=$TARGET_DIR/var/log
  61. LOG=$TMP/PKGTOOL.REMOVED
  62.  
  63. # remove whitespace
  64. crunch() {
  65.   while read FOO ; do
  66.     echo $FOO
  67.   done
  68. }
  69.  
  70. package_name() {
  71.   STRING=`basename $1 .tgz`
  72.   # Check for old style package name with one segment:
  73.   if [ "`echo $STRING | cut -f 1 -d -`" = "`echo $STRING | cut -f 2 -d -`" ]; then
  74.     echo $STRING
  75.   else # has more than one dash delimited segment
  76.     # Count number of segments:
  77.     INDEX=1
  78.     while [ ! "`echo $STRING | cut -f $INDEX -d -`" = "" ]; do
  79.       INDEX=`expr $INDEX + 1`
  80.     done
  81.     INDEX=`expr $INDEX - 1` # don't include the null value
  82.     # If we don't have four segments, return the old-style (or out of spec) package name:
  83.     if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then
  84.       echo $STRING
  85.     else # we have four or more segments, so we'll consider this a new-style name:
  86.       NAME=`expr $INDEX - 3`
  87.       NAME="`echo $STRING | cut -f 1-$NAME -d -`"
  88.       echo $NAME
  89.       # cruft for later ;)
  90.       #VER=`expr $INDEX - 2`
  91.       #VER="`echo $STRING | cut -f $VER -d -`"
  92.       #ARCH=`expr $INDEX - 1`
  93.       #ARCH="`echo $STRING | cut -f $ARCH -d -`"
  94.       #BUILD="`echo $STRING | cut -f $INDEX -d -`"
  95.     fi
  96.   fi
  97. }
  98.  
  99. remove_packages() {
  100.  for pkg_name in $* 
  101.  do
  102.   if [ -r $ADM_DIR/packages/$pkg_name ]; then
  103.    dialog --title "PACKAGE REMOVAL IN PROGRESS" --cr-wrap --infobox \
  104. "\nRemoving package $pkg_name.\n\
  105. \n\
  106. Since each file must be checked \
  107. against the contents of every other installed package to avoid wiping out \
  108. areas of overlap, this process can take quite some time. If you'd like to \
  109. watch the progress, flip over to another virtual console and type:\n\
  110. \n\
  111. tail -f $TMP/PKGTOOL.REMOVED\n" 13 60
  112.    export ROOT=$TARGET_DIR
  113.    removepkg $pkg_name >> $LOG 2> /dev/null
  114.   else
  115.    echo "No such package: $pkg_name. Can't remove." >> $LOG
  116.   fi
  117.  done
  118. }
  119.  
  120. # Here, we read the list of arguments passed to the pkgtool script.
  121. if [ $# -gt 0 ]; then # there are arguments to the command
  122.  while [ $# -gt 0 ]; do
  123.   case "$1" in
  124.   "-sets")
  125.    DISK_SETS=`echo $2 | tr "[A-Z]" "[a-z]"` ; shift 2 ;;
  126.   "-source_mounted")
  127.    SOURCE_MOUNTED="always" ; shift 1 ;;
  128.   "-ignore_tagfiles")
  129.    ASK="never" ; shift 1 ;;
  130.   "-tagfile")
  131.    USETAG=$2 ; shift 2 ;;
  132.   "-source_dir")
  133.    SOURCE_DIR=$2 ; shift 2 ;;
  134.   "-target_dir")
  135.    TARGET_DIR=$2
  136.    ADM_DIR=$TARGET_DIR/var/log
  137.    shift 2 ;;
  138.   "-source_device")
  139.    SOURCE_DEVICE=$2 ; shift 2 ;;
  140.   esac
  141.  done
  142. else  # there were no arguments, so we'll get the needed information from the
  143.       # user and then go on.
  144.  CMD_START="true"
  145.  rm -f $TMP/SeT*
  146.  while [ 0 ]; do
  147.   dialog --title "Slackware Package Tool (pkgtool version 9.0.0)" \
  148. --menu "\nWelcome to the Slackware package tool.\n\
  149. \nWhich option would you like?\n" 17 75 7 \
  150. "Current" "Install packages from the current directory" \
  151. "Other" "Install packages from some other directory" \
  152. "Floppy" "Install packages from floppy disks" \
  153. "Remove" "Remove packages that are currently installed" \
  154. "View" "View the list of files contained in a package" \
  155. "Setup" "Choose Slackware installation scripts to run again" \
  156. "Exit" "Exit Pkgtool" 2> $TMP/reply
  157.   if [ ! $? = 0 ]; then
  158.    rm -f $TMP/reply
  159.    dialog --clear
  160.    exit
  161.   fi
  162.   REPLY="`cat $TMP/reply`"
  163.   rm -f $TMP/reply
  164.   if [ "$REPLY" = "Exit" ]; then
  165.    dialog --clear
  166.    exit
  167.   fi
  168.   if [ "$REPLY" = "Setup" ]; then
  169.     echo 'dialog --title "SELECT SYSTEM SETUP SCRIPTS" --item-help --checklist \
  170.     "Please use the spacebar to select the setup scripts to run.  Hit enter when you \
  171. are done selecting to run the scripts." 17 70 9 \' > $TMP/setupscr
  172.     for script in $ADM_DIR/setup/setup.* ; do
  173.       BLURB=`grep '#BLURB' $script | cut -b8-`
  174.       if [ "$BLURB" = "" ]; then
  175.         BLURB="\"\""
  176.       fi
  177.       echo " \"`basename $script | cut -f2- -d .`\" $BLURB \"no\" $BLURB \\" >> $TMP/setupscr 
  178.     done
  179.     echo "2> $TMP/return" >> $TMP/setupscr
  180.     . $TMP/setupscr
  181.     if [ ! "`cat $TMP/return`" = "" ]; then
  182.       # Run each script:
  183.       for script in `cat $TMP/return` ; do
  184.         scrpath=$ADM_DIR/setup/setup.`echo $script | tr -d \"`
  185.         rootdevice="`mount | head -n 1 | cut -f 1 -d ' '`"
  186.         ( COLOR=on ; cd $TARGET_DIR ; . $scrpath / $rootdevice )
  187.       done
  188.     fi
  189.     rm -f $TMP/return $TMP/setupscr
  190.     continue
  191.   fi # end Setup
  192.   if [ "$REPLY" = "View" ]; then
  193.    DEFITEM=""
  194.    export DEFITEM
  195.    dialog --title "SCANNING" --infobox "Please wait while \
  196. Pkgtool scans your system to determine which packages you have \
  197. installed and prepares a list for you." 0 0
  198.    echo 'dialog $DEFITEM --item-help --menu "Please select the package you wish to view." 17 68 10 \' > $TMP/viewscr
  199.    for name in `ls $ADM_DIR/packages` ; do
  200.     pkg_name=`package_name $name`
  201.     BLURB="`sed -n \"/$pkg_name:/{s/\\"//g;p;q;}\" $ADM_DIR/packages/$name | cut -f 2- -d : | crunch`"
  202.     # Let's have some backward compatibility with the interim beta (for now):
  203.     if [ "$BLURB" = "" ]; then
  204.      BLURB="`sed -n \"/$name:/{s/\\"//g;p;q;}\" $ADM_DIR/packages/$name | cut -f 2- -d : | crunch`"
  205.     fi 
  206.     echo " \"$name\" \"$BLURB\" \"View information about package $name\" \\" >> $TMP/viewscr
  207.    done
  208.    echo "2> $TMP/return" >> $TMP/viewscr
  209.    while [ 0 ]; do
  210.     . $TMP/viewscr
  211.     if [ ! "`cat $TMP/return`" = "" ]; then
  212.      DEFITEM="--default-item `cat $TMP/return`"
  213.      dialog --title "CONTENTS OF PACKAGE: `cat $TMP/return`" --no-shadow --textbox "$ADM_DIR/packages/`cat $TMP/return`" \
  214.      0 0 2> /dev/null
  215.     else
  216.      break 
  217.     fi
  218.    done
  219.    rm -f $TMP/return $TMP/viewscr $TMP/tmpmsg
  220.    # This will clean up after most defective packages:
  221.    chmod 755 /
  222.    chmod 1777 /tmp
  223.    continue
  224.   fi  
  225.   if [ "$REPLY" = "Remove" ]; then
  226.    dialog --title "SCANNING" --infobox "Please wait while Pkgtool scans \
  227. your system to determine which packages you have installed and prepares \
  228. a list for you." 0 0
  229.    # end section
  230.    cat << EOF > $TMP/rmscript
  231. dialog --title "SELECT PACKAGES TO REMOVE" --item-help --checklist \
  232. "Please select the \
  233. packages you wish to Remove. Use the \
  234. spacebar to select packages to delete, and the UP/DOWN arrow keys to \
  235. scroll up and down through the entire list." 20 75 11 \\
  236. EOF
  237.    for name in `ls $ADM_DIR/packages` ; do
  238.     pkg_name=`package_name $name`
  239.     BLURB="`sed -n \"/$pkg_name:/{s/\\"//g;p;q;}\" $ADM_DIR/packages/$name | cut -f 2- -d : | crunch`"
  240.     # Let's have some backward compatibility with the interim beta (for now):
  241.     if [ "$BLURB" = "" ]; then
  242.      BLURB="`sed -n \"/$name:/{s/\\"//g;p;q;}\" $ADM_DIR/packages/$name | cut -f 2- -d : | crunch`"
  243.     fi 
  244.     echo " \"$name\" \"$BLURB\" off \"Select/Unselect removing package $name\" \\" >> $TMP/rmscript
  245.    done 
  246.    echo "2> $TMP/return" >> $TMP/rmscript
  247.    if [ -L $LOG -o -r $LOG ]; then
  248.      rm -f $LOG
  249.    fi
  250.    cat /dev/null > $LOG
  251.    chmod 600 $LOG
  252.    chmod 700 $TMP/rmscript
  253.    export ADM_DIR;
  254.    $TMP/rmscript
  255.    remove_packages `cat $TMP/return | tr -d "\042"`
  256.    if [ "`cat $TMP/PKGTOOL.REMOVED`" = "" ]; then
  257.     rm -f $TMP/PKGTOOL.REMOVED
  258.     dialog --title "NO PACKAGES REMOVED" --msgbox "Hit OK to return \
  259. to the main menu." 5 40
  260.    else
  261.     dialog --title "PACKAGE REMOVAL COMPLETE" --msgbox "The packages have \
  262. been removed. A complete log of the files that were removed has been created \
  263. in $TMP: PKGTOOL.REMOVED." 0 0
  264.    fi
  265.    rm -f $TMP/rmscript $TMP/return $TMP/tmpmsg $TMP/SeT*
  266.    chmod 755 /
  267.    chmod 1777 /tmp
  268. # No, return to the main menu:
  269. #   exit
  270.   elif [ "$REPLY" = "Floppy" ]; then
  271.    dialog --title "SELECT FLOPPY DRIVE" --menu "Which floppy drive would \
  272. you like to install from?" \
  273. 11 70 4 \
  274. "/dev/fd0u1440" "1.44 MB first floppy drive" \
  275. "/dev/fd1u1440" "1.44 MB second floppy drive" \
  276. "/dev/fd0h1200" "1.2 MB first floppy drive" \
  277. "/dev/fd1h1200" "1.2 MB second floppy drive" 2> $TMP/wdrive
  278.    if [ $? = 1 ]; then
  279.     dialog --clear
  280.     exit
  281.    fi
  282.    SOURCE_DEVICE="`cat $TMP/wdrive`"
  283.    rm -f $TMP/wdrive 
  284.    cat << EOF > $TMP/tmpmsg
  285.  
  286. Enter the names of any disk sets you would like to install.
  287. Separate the sets with a space, like this: a b oi x
  288.  
  289. To install packages from one disk, hit [enter] without typing
  290. anything.
  291.  
  292. EOF
  293.    dialog --title "SOFTWARE SELECTION" --inputbox "`cat $TMP/tmpmsg`" 13 70 2> $TMP/sets 
  294.    DISK_SETS="`cat $TMP/sets`"
  295.    rm -f $TMP/sets
  296.    if [ "$DISK_SETS" = "" ]; then
  297.     DISK_SETS="disk"
  298.    else
  299.     DISK_SETS=`echo $DISK_SETS | sed 's/ /#/g'`
  300.     DISK_SETS="#$DISK_SETS"
  301.    fi
  302.    break;
  303.   elif [ "$REPLY" = "Other" ]; then
  304.    dialog --title "SELECT SOURCE DIRECTORY" --inputbox "Please enter the name of the directory that you wish to \
  305. install packages from:" 10 50 2> $TMP/pkgdir
  306.    if [ $? = 1 ]; then
  307.     rm -f $TMP/pkgdir $TMP/SeT*
  308.     dialog --clear
  309.     exit
  310.    fi 
  311.    SOURCE_DIR="`cat $TMP/pkgdir`"
  312.    SOURCE_MOUNTED="always"
  313.    DISK_SETS="disk" 
  314.    chmod 755 $TARGET_DIR
  315.    chmod 1777 $TARGET_DIR/tmp
  316.    rm -f $TMP/pkgdir
  317.    if [ ! -d $SOURCE_DIR ]; then
  318.     dialog --title "DIRECTORY NOT FOUND" --msgbox "The directory you want to \
  319. install from ($SOURCE_DIR) \
  320. does not seem to exist. Please check the directory and then try again." \
  321. 10 50
  322.     dialog --clear
  323.     exit
  324.    fi
  325.    break;
  326.   else # installing from current directory
  327.    SOURCE_MOUNTED="always"
  328.    SOURCE_DIR="$PWD"
  329.    DISK_SETS="disk" 
  330.    chmod 755 $TARGET_DIR
  331.    chmod 1777 $TARGET_DIR/tmp
  332.    break;
  333.   fi 
  334.  done
  335. fi
  336. if [ "$DISK_SETS" = "disk" ]; then
  337.  ASK="always"
  338. fi
  339.  
  340. mount_the_source() {
  341.  # is the source supposed to be mounted already?
  342.  if [ "$SOURCE_MOUNTED" = "always" ]; then
  343.   # The source should already be mounted, so we test it
  344.   if [ ! -d $SOURCE_DIR ]; then # the directory is missing
  345.    cat << EOF > $TMP/tmpmsg
  346.  
  347. Your source device cannot be accessed properly.
  348.  
  349. Please be sure that it is mounted on $SOURCE_DIR,
  350. and that the Slackware disks are found in subdirectories 
  351. of $SOURCE_DIR like specified.
  352.  
  353. EOF
  354.    dialog --title "MOUNT ERROR" --msgbox "`cat $TMP/tmpmsg`" 11 67
  355.    rm -f $TMP/tmpmsg
  356.    exit 1;
  357.   fi
  358.   return 0;
  359.  fi
  360.  dialog --title "INSERT DISK" --menu "Please insert disk $1 and \
  361. press ENTER to continue." \
  362. 11 50 3 \
  363. "Continue" "Continue with the installation" \
  364. "Skip" "Skip the current disk series" \
  365. "Quit" "Abort the installation process" 2> $TMP/reply
  366.  if [ ! $? = 0 ]; then
  367.   REPLY="Quit"
  368.  else
  369.   REPLY="`cat $TMP/reply`"
  370.  fi
  371.  rm -f $TMP/reply
  372.  if [ "$REPLY" = "Skip" ]; then
  373.   return 1;
  374.  fi
  375.  if [ "$REPLY" = "Quit" ]; then
  376.    dialog --title "ABORTING" --msgbox "Aborting software installation." 5 50
  377.    chmod 755 $TARGET_DIR
  378.    chmod 1777 $TARGET_DIR/tmp
  379.    exit 1;
  380.  fi;
  381.  # Old line:
  382.  # mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
  383.  # New ones: (thanks to Andy Schwierskott!)
  384.  go_on=y
  385.  not_successfull_mounted=1
  386.  while [ "$go_on" = y -a "$not_successfull_mounted" = 1 ]; do
  387.   mount -r -t msdos $SOURCE_DEVICE $SOURCE_DIR
  388.   not_successfull_mounted=$?
  389.   if [ "$not_successfull_mounted" = 1 ]; then
  390.    mount_answer=x
  391.    while [ "$mount_answer" != "y" -a "$mount_answer" != "q" ] ; do
  392.     dialog --title "MOUNT PROBLEM" --menu "Media was not successfully \
  393. mounted! Do you want to \
  394. retry, or quit?" 10 60 2 \
  395. "Yes" "Try to mount the disk again" \
  396. "No" "No, abort." 2> $TMP/mntans
  397.     mount_answer="`cat $TMP/mntans`"
  398.     rm -f $TMP/mntans
  399.     if [ "$mount_answer" = "Yes" ]; then
  400.      mount_answer="y"
  401.     else
  402.      mount_answer="q"
  403.     fi
  404.    done
  405.    go_on=$mount_answer
  406.   fi
  407.  done
  408.  test $not_successfull_mounted = 0
  409. }
  410.  
  411. umount_the_source() {
  412.  if [ ! "$SOURCE_MOUNTED" = "always" ]; then
  413.   umount $SOURCE_DEVICE 1> /dev/null 2>&1
  414.  fi;
  415. }
  416.  
  417. install_disk() {
  418.  mount_the_source $1
  419.  if [ $? = 1 ]; then
  420.   umount_the_source;
  421.   return 1;
  422.  fi
  423.  CURRENT_DISK_NAME="$1"
  424.  PACKAGE_DIR=$SOURCE_DIR
  425.  if [ "$SOURCE_MOUNTED" = "always" -a ! "$DISK_SETS" = "disk" ]; then
  426.    PACKAGE_DIR=$PACKAGE_DIR/$1
  427.  fi
  428.  
  429.  # If this directory is missing or contains no *.tgz files, bail.
  430.  if [ ! -d $PACKAGE_DIR ]; then
  431.   return 1
  432.  fi
  433.  if ls $PACKAGE_DIR/*.tgz 1> /dev/null 2> /dev/null ; then
  434.   true
  435.  else
  436.   return 1
  437.  fi
  438.  
  439.  #
  440.  # look for tagfile for this series and copy into $TMP/tagfile
  441.  #
  442.  touch $TMP/tagfile
  443.  if [ ! "$DISK_SETS" = "disk" ]; then
  444.   if [ -r $TMP/SeTtagext ]; then
  445.    if [ -r $PACKAGE_DIR/tagfile`cat $TMP/SeTtagext` ]; then
  446.     cat $PACKAGE_DIR/tagfile`cat $TMP/SeTtagext` >> $TMP/tagfile
  447.    else
  448.     if [ -r $PACKAGE_DIR/tagfile ]; then
  449.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  450.     fi
  451.    fi
  452.  
  453.   #
  454.   # Do we need to follow a custom path to the tagfiles?
  455.   #
  456.   elif [ -r $TMP/SeTtagpath ]; then
  457.    custom_path=`cat $TMP/SeTtagpath`
  458.    short_path=`basename $PACKAGE_DIR`
  459.  
  460.    # If tagfile exists at the specified custom path, copy it over.
  461.    if [ -r $custom_path/$short_path/tagfile ]; then
  462.     cat $custom_path/$short_path/tagfile >> $TMP/tagfile
  463.  
  464.    else # well, I guess we'll use the default one then.
  465.     if [ -r $PACKAGE_DIR/tagfile ]; then
  466.      cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  467.     fi
  468.    fi
  469.   #
  470.   # We seem to be testing for this too often... maybe this code should
  471.   # be optimized a little...
  472.   # 
  473.   elif [ -r $PACKAGE_DIR/tagfile ]; then
  474.    cat $PACKAGE_DIR/tagfile >> $TMP/tagfile
  475.   fi
  476.  
  477.   #
  478.   # Execute menus if in QUICK mode:
  479.   #
  480.   if [ -r $TMP/SeTQUICK -a -r $PACKAGE_DIR/maketag ]; then
  481.    if [ ! "$MAKETAG" = "" -a -r $PACKAGE_DIR/$MAKETAG ]; then # use alternate maketag
  482.     sh $PACKAGE_DIR/$MAKETAG
  483.    else    
  484.     sh $PACKAGE_DIR/maketag
  485.    fi
  486.    if [ -r $TMP/SeTnewtag ]; then
  487.     mv $TMP/SeTnewtag $TMP/tagfile
  488.    fi
  489.   fi
  490.  
  491.   #
  492.   # Protect tagfile from hacker attack:
  493.   #
  494.   if [ -r $TMP/tagfile ]; then
  495.    chmod 600 $TMP/tagfile
  496.   fi
  497.  
  498.  fi #  ! "$DISK_SETS" = "disk" 
  499.  
  500.  # It's possible that the tagfile was specified on the command line.  If that's
  501.  # the case, then we'll just override whatever we figured out up above.
  502.  if [ ! "$USETAG" = "" ]; then
  503.    cat $USETAG > $TMP/tagfile
  504.  fi
  505.  
  506.  # If there's a catalog file present, use it to check for missing files.
  507.  # If not, forget about that and install whatever's there.
  508.  if [ "$1" = "single_disk" -o -r $PACKAGE_DIR/disk$1 -o -r $PACKAGE_DIR/package-list.txt ]; then
  509.   if [ -r $PACKAGE_DIR/package-list.txt ]; then
  510.    CATALOG_FILE=$PACKAGE_DIR/package-list.txt
  511.   else
  512.    CATALOG_FILE=`basename $PACKAGE_DIR/disk*`;
  513.   fi
  514.   if [ -r $PACKAGE_DIR/$CATALOG_FILE -a ! -d $PACKAGE_DIR/$CATALOG_FILE ]; then
  515.    if grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE 1> /dev/null 2>&1 ; then
  516.     # First we check for missing packages...
  517.     for PKGTEST in `grep "^CONTENTS:" $PACKAGE_DIR/$CATALOG_FILE | cut -f2- -d : 2> /dev/null` ; do
  518.      # This is not a perfect test.  (say emacs is missing but emacs-nox is not)
  519.      if ls $PACKAGE_DIR/$PKGTEST*.tgz 1> /dev/null 2> /dev/null ; then # found something like it
  520.       true
  521.      else
  522.       cat << EOF > $TMP/tmpmsg
  523.  
  524. WARNING!!!
  525.  
  526. While looking through your index file ($CATALOG_FILE),
  527. I noticed that you might be missing a package:
  528.  
  529. $PKGTEST-\*-\*-\*.tgz
  530.  
  531. that is supposed to be on this disk (disk $1). You may go
  532. on with the installation if you wish, but if this is a 
  533. crucial file I'm making no promises that your machine will
  534. boot.
  535.  
  536. EOF
  537.       dialog --title "FILE MISSING FROM YOUR DISK" --msgbox \
  538. "`cat $TMP/tmpmsg`" 17 67
  539.      fi
  540.     done # checking for missing packages
  541.     # Now we test for extra packages:
  542.     ALLOWED="`grep CONTENTS: $PACKAGE_DIR/$CATALOG_FILE | cut -b10- 2> /dev/null`" 
  543.     for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  544.      BASE="`basename $PACKAGE_FILENAME .tgz`"
  545.      BASE="`package_name $BASE`"
  546.      if echo $ALLOWED | grep $BASE 1> /dev/null 2>&1 ; then
  547.       true
  548.      else
  549.       cat << EOF > $TMP/tmpmsg
  550.  
  551. WARNING!!!
  552.  
  553. While looking through your index file ($CATALOG_FILE),
  554. I noticed that you have this extra package:
  555.  
  556. ($BASE.tgz) 
  557.  
  558. that I don't recognize. Please be sure this package is
  559. really supposed to be here, and is not left over from an
  560. old version of Slackware. Sometimes this can happen at the 
  561. archive sites.
  562.  
  563. EOF
  564.       dialog --title "EXTRA FILE FOUND ON YOUR DISK" \
  565. --msgbox "`cat $TMP/tmpmsg`" 17 67 
  566.       rm -f $TMP/tmpmsg
  567.      fi
  568.     done 
  569.    fi
  570.   fi
  571.  fi # check for missing/extra packages
  572.  
  573.  # Install the packages:
  574.  for PACKAGE_FILENAME in $PACKAGE_DIR/*.tgz; do
  575.   if [ "$PACKAGE_FILENAME" = "$PACKAGE_DIR/*.tgz" ]; then
  576.    continue;
  577.   fi
  578.   if [ "$ASK" = "never" ]; then # install the package
  579.    installpkg -root $TARGET_DIR -infobox -tagfile $TMP/tagfile $PACKAGE_FILENAME
  580.    ERROR=$?
  581.   elif [ "$ASK" = "tagfiles" ]; then
  582.    installpkg -root $TARGET_DIR -menu -tagfile $TMP/tagfile $PACKAGE_FILENAME
  583.    ERROR=$?
  584.   else # ASK should be = always here, and that's how we'll treat it
  585.    installpkg -root $TARGET_DIR -menu -ask -tagfile $TMP/tagfile $PACKAGE_FILENAME
  586.    ERROR=$?
  587.   fi
  588.   # Check for abort:
  589.   if [ "$ERROR" = "99" ]; then
  590.    umount_the_source;
  591.    chmod 755 $TARGET_DIR
  592.    chmod 1777 $TARGET_DIR/tmp
  593.    exit 1;
  594.   fi
  595.   # Present a warning if an error is found:
  596.   if [ ! "$ERROR" = "0" ]; then
  597.    dialog --timeout 600 --title "installpkg error #$ERROR" --msgbox "There was a fatal \
  598. error attempting to install $PACKAGE_FILENAME.  The package may be corrupt, \
  599. the installation media may be bad, or something else has caused the package \
  600. to be unable to be read without error.  You may hit enter to continue if you wish, \
  601. but if this is an important required package then your \
  602. installation may not work as-is." 11 70 
  603.   fi
  604.  done
  605.  OUTTAHERE="false"
  606.  if [ -r $PACKAGE_DIR/install.end ]; then
  607.   OUTTAHERE="true"
  608.  fi
  609.  umount_the_source;
  610.  if [ "$OUTTAHERE" = "true" ]; then
  611.   return 1;
  612.  fi
  613. }
  614.  
  615. install_disk_set() { # accepts one argument: the series name in lowercase.
  616.  SERIES_NAME=$1
  617.  CURRENT_DISK_NUMBER="1";
  618.  while [ 0 ]; do
  619.   # Don't start numbering the directories until 2:
  620.   if [ $CURRENT_DISK_NUMBER = 1 ]; then
  621.     DISKTOINSTALL=$SERIES_NAME
  622.   else
  623.     DISKTOINSTALL=$SERIES_NAME$CURRENT_DISK_NUMBER
  624.   fi
  625.   install_disk $DISKTOINSTALL
  626.   if [ ! $? = 0 ]; then # install.end was found, or the user chose
  627.         # to quit installing packages.
  628.    return 0;
  629.   fi
  630.   CURRENT_DISK_NUMBER=`expr $CURRENT_DISK_NUMBER + 1`
  631.  done;
  632. }
  633.  
  634. # /* main() */ ;)
  635. if [ "$DISK_SETS" = "disk" ]; then
  636.  install_disk single_disk;
  637.  ASK="always"
  638. else
  639.  touch $TMP/tagfile
  640.  chmod 600 $TMP/tagfile
  641.  if echo $DISK_SETS | grep "#a#" 1> /dev/null 2>&1; then
  642.   A_IS_NEEDED="true"
  643.  else
  644.   A_IS_NEEDED="false"
  645.  fi
  646.  while [ 0 ];
  647.  do
  648.   while [ 0 ]; # strip leading '#'s
  649.   do
  650.    if [ "`echo $DISK_SETS | cut -b1`" = "#" ]; then
  651.     DISK_SETS="`echo $DISK_SETS | cut -b2-`"
  652.    else
  653.     break;
  654.    fi
  655.   done
  656.   if [ "$A_IS_NEEDED" = "true" ]; then
  657.    cat << EOF > $TMP/tmpmsg
  658.  
  659. --- Installing package series ==>a<==
  660.  
  661. EOF
  662.    dialog --infobox "`cat $TMP/tmpmsg`" 5 45
  663.    sleep 1
  664.    rm -f $TMP/tmpmsg
  665.    install_disk_set a;
  666.    A_IS_NEEDED="false"
  667.   fi
  668.   count="1"
  669.   if [ "`echo $DISK_SETS | cut -b$count`" = "" ]; then
  670.    break; # we be done here :^)
  671.   else
  672.    count="2"
  673.    while [ 0 ]; do
  674.     if [ "`echo $DISK_SETS | cut -b$count`" = "" -o "`echo $DISK_SETS | cut -b$count`" = "#" ]; then
  675.      count="`expr $count - 1`"
  676.      break;
  677.     else
  678.      count="`expr $count + 1`"
  679.     fi 
  680.    done
  681.   fi 
  682.   diskset="`echo $DISK_SETS | cut -b1-$count`"
  683.   count="`expr $count + 1`"
  684.   DISK_SETS="`echo $DISK_SETS | cut -b$count-`"
  685.   if [ "$diskset" = "a" ]; then
  686.    continue; # we expect this to be done elsewhere
  687.   fi
  688.   cat << EOF > $TMP/tmpmsg
  689.  
  690. Installing package series ==>$diskset<==
  691.  
  692. EOF
  693.   dialog --infobox "`cat $TMP/tmpmsg`" 5 45
  694.   sleep 1
  695.   rm -f $TMP/tmpmsg
  696.   install_disk_set $diskset; 
  697.  done
  698. fi
  699.  
  700. if [ "$DISK_SETS" = "disk" -o "$CMD_START" = "true" ]; then
  701.  if [ -r $TMP/tagfile ]; then
  702.   rm $TMP/tagfile
  703.  fi
  704.  dialog --clear
  705. fi
  706. chmod 755 $TARGET_DIR $TARGET_DIR/var $TARGET_DIR/usr
  707. chmod 1777 $TARGET_DIR/tmp
  708.